home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5193 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.1 KB  |  57 lines

  1. Newsgroups: comp.lang.c++
  2. Path: howland.reston.ans.net!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: Re: simple design question
  5. Message-ID: <DM62yo.15p@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <DM4u8I.G1H@emr1.emr.ca> <4etef2$3sc@newsroom.hitc.com>
  8. Date: Fri, 2 Feb 1996 21:13:36 GMT
  9.  
  10. In article <4etef2$3sc@newsroom.hitc.com> psand@eos.hitc.com (G. Patrick Sand) writes:
  11. >In article <DM4u8I.G1H@emr1.emr.ca>, jagrant@emr1.emr.ca says...
  12. >>
  13. >>This is a design question, not a syntax question, so forgive the pseudo-
  14. >>code.
  15. >>
  16. >>I'm trying to design/write a class for complex file I/O (I'll state it
  17. >>in simple terms here).
  18. >>
  19. >>I want to use it like this:
  20. >>        object.Open("xxx")
  21. >>        for(...){
  22. >>          object.Read(stuff);
  23. >>        }
  24. >>        object.Close();
  25. >>
  26. >>But I want to also have a single function that will Open/Read/Close in a
  27. >>single operation:
  28. >>        object.GetData("xxx",stuff);
  29. >>
  30. >
  31. >Okay, the first question is this:
  32. >
  33. >1. Do you want to reuse the open/close/read semantics in other classes?
  34. >If so, make it a separate class and use inheritance to add it to classes 
  35. >where you wish to do complex I/O.  If not, just make them methods in the 
  36. >desired class.  I recommend that if you have 2 or more classes which will 
  37. >do this I/O create the I/O operations as a separate class and 
  38. >inherit--this is one of the maintenance blessing C++ and OOA/D confers on 
  39. >you...if you use it...
  40.     I was just thinking about this as a standalone class for now -it's
  41.     actually complex enough now (I didn't supply the details).
  42.     No, I can't see adding it to any other classes.
  43.  
  44.     No offence, but I don't think you've fully appreciated the specific
  45.     question I originally asked. I won't repeat it again but it was
  46.     related to the possible corruption by GetData() of internal stuff
  47.     used by Open/Read/Close.
  48.  
  49. >The second question is this:
  50. >
  51. >2. Why not use the iostreams/fstreams stuff?  It does deal with 
  52.     [..perhaps but irrelevant for this problem and C streams are fine...]
  53. -- 
  54. John A. Grant                        jagrant@emr1.emr.ca
  55. Airborne Geophysics
  56. Geological Survey of Canada, Ottawa
  57.